package com.example.liwushuo.adapter;

import java.util.List;

import com.example.liwushuo.BaseApp;
import com.example.liwushuo.R;
import com.example.liwushuo.bean.HomeItem;
import android.content.Context;
import android.util.Log;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

public class SelectionAdapter extends AppAdapter<HomeItem> {

	public SelectionAdapter(Context context, List<HomeItem> list) {
		super(context, list);
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		ViewHolder holder;
		if (convertView == null) {

			convertView = inflater.inflate(R.layout.selection_item, null);
			holder = new ViewHolder(convertView);
			convertView.setTag(holder);
		} else {
			holder = (ViewHolder) convertView.getTag();
		}
		Log.i("ImageUrl", "----------" + list.get(position).getContent_url());
		holder.info.setText(list.get(position).getTitle());
		holder.feed_count.setText(list.get(position).getLikes_count());
		BaseApp.getBitmapUtils().display(holder.img,
				list.get(position).getCover_image_url());
		return convertView;
	}

	private static class ViewHolder {

		ImageView img;
		TextView info;
		TextView feed_count;

		public ViewHolder(View view) {

			img = (ImageView) view.findViewById(R.id.selection_img);
			info = (TextView) view.findViewById(R.id.selection_info);
			feed_count = (TextView) view.findViewById(R.id.feed_count);

		}
	}

}
